<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta http-equiv="Cache-Control" content="no-cache,must-revalidate">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta name="format-detection" content="telephone=no, address=no">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black-translucent" name="apple-mobile-web-app-status-bar-style">
    <title></title>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css">
    <link href="https://cdn.bootcss.com/jquery-mobile/1.4.5/jquery.mobile.theme.css" rel="stylesheet">
    <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>


    <script type="text/javascript">

        $(function () {
            showMyMeetings();
        });


        function showMyMeetings() {


            var pid = $("#pid").val();
            $("#two").empty();

            $.ajax({
                type: "get",
                url: "/meetingPub/selectUserMeetingGrabByPid",
                data: {"pid": pid},
                success: function (msg) {
                    var code = msg.code;
                    if (code == "2000") {
                        var objs = msg.data;
                        var appendHtml = "<font style='padding: 10px 10px 10px 15px;display: block;color: #777777;'>共有" + objs.length + "人参与抢单</font>";
                        for (var i = 0; i < objs.length; i++) {
                            var name = objs[i].name;
                            var province = objs[i].province;
                            var city = objs[i].city;
                            var uid = objs[i].id;
                            var grabStatus = objs[i].meetingGrab.grabStatus;

                            appendHtml += "<div style='width: 100%;background-color: white;margin-top: -3px;padding:10px 10px 10px 15px;display: inline-block;'>" +
                                "<div style='width: 70%;float: left;' onclick='showMeetingInfo(\"" + 1 + "\");'>" +
                                "<div style='white-space: nowrap;overflow: hidden;text-overflow:ellipsis;display: block;font-size:18px;'>" +
                                name + "</div>" +
                                "<div style='white-space: nowrap;overflow: hidden;text-overflow:ellipsis;display: block;color: #777777;font-size:16px;padding-top:1px'>" +
                                province + " / " + city + "</div></div>" +
                                "<div style='width: 30%;float: right;'>";
                            if (grabStatus == 0) {
                                appendHtml += "<button class='able-btn' onclick='chooseGrap(\"" + uid + "\")' >就选你</button>";
                            } else if (grabStatus == 1) {
                                appendHtml += "<button class='able-btn'>已选择</button>";
                            } else {
                                appendHtml += "<button class='able-btn'>未选择</button>";
                            }
                            appendHtml += "</div></div>";

                        }
                        $("#two").append(appendHtml);
                    } else if (code == "2003") {
                        appendHtml = "<font style='padding: 10px 10px 10px 15px;display: block;color: #777777;'>暂时还没有讲师抢单</font>";
                        $("#two").append(appendHtml);
                    }
                }
            });
        }

        function chooseGrap(uid) {
            if (confirm("确定要选择该讲师成功本次会议讲者?")) {
                var pid = $("#pid").val();
                $.ajax({
                    type: "get",
                    url: "/meetingPub/updateMeetingGrabChoose",
                    data: {"pid": pid, "uid": uid},
                    success: function (msg) {
                        var code = msg.code;
                        if (code == "2000") {
                            alert("讲者设定成功")
                            window.location.href = "/meetingPub/meetingPubToGrabList?pid=" + pid;
                        } else {
                            alert("网络异常,请刷新重试")
                        }
                    }
                });
            }
        }

    </script>
</head>
<body>
<form name="formMeetingInfo" action="" method="post">
    <input type="hidden" id="pid" name="pid" th:value="${pid}">
</form>
<div data-role="page" id="pageDetail">
    <div style="padding:0px;background-color: #4E90C7;width: 100%;height:40px;line-height:40px;font-size:18px;text-align: center;cursor: pointer;"
         data-role="none">
        <div style="color: white;" onclick="showMyMeetings();" id="two_tab">抢单者列表</div>
    </div>
    <div id="two" class="ui-body-d ui-content" style="padding: 0;width: 100%;">

    </div>
</div>
</body>

</html>
